package com.aaron.kjviewutils.utils;

import android.content.Context;

import cn.sharesdk.framework.Platform;
import cn.sharesdk.framework.PlatformActionListener;
import cn.sharesdk.framework.ShareSDK;
import cn.sharesdk.wechat.friends.Wechat;
import cn.sharesdk.wechat.moments.WechatMoments;

/**
 * Created by Aaron on 2017/3/7.
 */

public class ShareUtils {

    private PlatformActionListener platformActionListener;

    public ShareUtils( PlatformActionListener platformActionListener)
    {
        this.platformActionListener = platformActionListener;
    }

    public void share(String shareTag)
    {
        Platform.ShareParams params = new Platform.ShareParams();
        params.setShareType(Platform.SHARE_WEBPAGE);
        params.setTitle("用呗内版用呗上线啦");
        params.setText("用呗，让你的生活更精彩");
        params.setUrl("http://git.oschina.net/Aaron_CN1987/MaterialUi");
        params.setImageUrl("http://git.oschina.net/assets/qrcode-weixin-0133b31ee0f8fd2d88eee0821788abda.jpg");
        switch (shareTag)
        {
            case "wechat":
            {
                //分享到朋友
                Platform wechat = ShareSDK.getPlatform(Wechat.NAME);
                wechat.setPlatformActionListener(platformActionListener);
                wechat.share(params);
            }
            break;
            case "moments":
            {
                //分享到朋友圈
                Platform wechat = ShareSDK.getPlatform(WechatMoments.NAME);
                wechat.setPlatformActionListener(platformActionListener);
                wechat.share(params);
            }
            break;
            default:
                break;
        }
    }
}
